package com.example.myapplication.slice;

import com.example.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;

import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_CONTENT;
import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_PARENT;

public class MainAbility2Slice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
//        super.setUIContent(ResourceTable.Layout_ability_main2);
        DependentLayout dependentLayout=new DependentLayout(this);
        dependentLayout.setWidth(MATCH_PARENT);
        dependentLayout.setHeight(MATCH_PARENT);
        ShapeElement element=new ShapeElement();
        element.setRgbColor(new RgbColor(0,0,0));
        dependentLayout.setBackground(element);
        Text text=new Text(this);
        text.setText("你妈嗨");
        text.setWidth(MATCH_PARENT);
        text.setTextSize(80);
        text.setTextColor(Color.RED);
        DependentLayout.LayoutConfig layoutConfig=new DependentLayout.LayoutConfig(MATCH_CONTENT,MATCH_CONTENT);
        layoutConfig.addRule(DependentLayout.LayoutConfig.CENTER_IN_PARENT);
        text.setLayoutConfig(layoutConfig);
        dependentLayout.addComponent(text);
        super.setUIContent(dependentLayout);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
